;(function($,dc){
    var defaults = {
        time : 2,
        skin : "white", //black
        type : "msg", //alert
        title: "提示",
        content: "content",

    };
    var settings = {};
    $.MSG = {
        show   : function(options){
            settings = $.extend({}, defaults, options);
            $th = this;
            $LxyMsg = this.MsgDom();
            
            switch(settings.type){
                case "alert" :
                        $LxyMsg.children(".content").html(settings.content);
                        $LxyMsg.fadeIn("fast","swing");
                        $LxyMsg.find(".btn_cancel").unbind("click").on("click",function(){
                            if(settings.btn_cancel){
                                settings.btn_cancel();
                            }else{
                                 $th.close();
                            }
                        });

                        $LxyMsg.find(".btn_confirm").unbind("click").on("click",function(){
                            if(settings.btn_confirm){
                                settings.btn_confirm();
                            }else{
                                 $th.close();
                            }
                        });
                break;
                case "msg" :
                default:
                    $LxyMsg.html(settings.content);
                    $LxyMsg.fadeIn("fast","swing");
                    this.close();
                break;
            }
            
        },

        close  : function(){
            var msgclose = function(){
                $LxyMsg.fadeOut("slow",function(){
                    if(settings.callback){
                        settings.callback();
                    }
                });
            }
            if(settings.type == "msg"){
                setTimeout(msgclose,settings.time * 1000);
            }else{
                $LxyMsg.fadeOut(100);
            }

            
        },

        init   : function(options){            
            this.debug(settings);            
            return this;
        },

        debug  : function(obj){
            console.log(obj);
        },

        MsgDom : function(){
            var MsgID = "LxyMsg_"+settings.type;
            if($("#"+MsgID).length == 0){
                var html = '';
                switch(settings.type){
                    case "alert" :
                        html += '<div id="'+ MsgID +'" class="alert"><div class="content">' +settings.content+ '</div><div class="btns"><a href="javascript:;" class="btn_cancel">取消</a><a href="javascript:;" class="btn_confirm">确定</a></div></div>';
                    break;
                    case "msg" :
                    default:
                        html += '<div id="'+ MsgID +'" class="'+ settings.skin +'">'+ settings.content +'</div>';
                    break;
                }
                $("body").append(html);
            }
            return $("#"+MsgID);
        },

    };


})(jQuery,document);




